﻿#region Header
// Copyright 2007-2011, Jerónimo Milea
// 
// This file is part of NetJsWire.
// 
//     NetJsWire is free software: you can redistribute it and/or modify
//     it under the terms of the GNU General Public License as published by
//     the Free Software Foundation, either version 3 of the License, or
//     (at your option) any later version.
// 
//     NetJsWire is distributed in the hope that it will be useful,
//     but WITHOUT ANY WARRANTY; without even the implied warranty of
//     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//     GNU General Public License for more details.
// 
//     You should have received a copy of the GNU General Public License
//     along with NetJsWire.  If not, see <http://www.gnu.org/licenses/>.
#endregion

using System;
using System.Web;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

namespace NetJsWire.Direct
{
    [JsonObject]
    public class DirectRequest
    {

        public const string RequestFormTransactionId = "extTID";
        public const string RequestFormAction = "extAction";
        public const string RequestFormMethod = "extMethod";
        public const string RequestFormUpload = "extUpload";
        public const string RequestFormType = "extType";

        internal DirectRequest() 
        { }
        internal DirectRequest(JObject actionObject)
        {
            Action = ((string)actionObject["action"]);
            Method = ((string)actionObject["method"]);
           
            TransactionId = ((int)actionObject["tid"]);
            
            Type = ((string)actionObject["type"]);
            Data = actionObject["data"];
        }

        [JsonProperty("action")]
        public string Action
        {
            get;
            set;
        }

        [JsonProperty("method")]
        public string Method
        {
            get;
            set;
        }

        public HttpRequest HttpRequest
        {
            get;
            set;
        }

        
        [JsonProperty("data")]
        public Object Data
        {
            get;
            set;
        }

        [JsonProperty("type")]
        public string Type
        {
            get;
            set;
        }

        public bool IsForm
        {
            get;
            set;
        }

        public bool IsUpload
        {
            get;
            set;
        }

        [JsonProperty(PropertyName = "tid")]
        public int TransactionId
        {
            get;
            set;
        }

    }

}
